﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Commons
{
    /// <summary>
    /// 返回结果类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ResultType<T>
    {
        public ResultType()
        {
            if (typeof(T).IsClass && typeof(T) != typeof(string))
            {
                Data = Activator.CreateInstance<T>();
            }
            ResultCode = 0;
        }
        public ResultType(int errorCode, string resultMsg, T data)
        {
            ResultCode = errorCode;
            ResultMsg = resultMsg;
            Data = data;
        }
        /// <summary>
        /// 0成功，1错误
        /// </summary>
        public int ResultCode { get; set; }
        /// <summary>
        /// 文字描述信息
        /// </summary>
        public String ResultMsg { get; set; }
        /// <summary>
        /// 泛型自定义数据
        /// </summary>
        public T Data { get; set; }

    }

    /// <summary>
    /// 返回结果类
    /// </summary>
    public class ResultType
    {
        public ResultType()
        {
            ResultCode = 0;
        }
        public ResultType(int errorCode, string resultMsg)
        {
            ResultCode = errorCode;
            ResultMsg = resultMsg;
        }
        /// <summary>
        /// 0成功，1错误
        /// </summary>
        public int ResultCode { get; set; }
        /// <summary>
        /// 文字描述信息
        /// </summary>
        public String ResultMsg { get; set; }

    }
}
